<template>
  <div>
      <div class="container">
          <el-breadcrumb separator="/">
              <el-breadcrumb-item class="mg">
                 <i class="el-icon-s-platform gre"></i> 添加
              </el-breadcrumb-item>
          </el-breadcrumb>
          <div class="handle-box">
              <span>分类名称：</span><el-input v-model="query.name" placeholder="用户名称" class="handle-input mr10"></el-input>
              <span>分类顺序：</span><el-input v-model="query.phone" placeholder="手机号" class="handle-input mr10"></el-input>
              <el-button type="primary" class="Btn" @click="handleKeep">保存</el-button>
          </div>
          <hr>
          <p class="mt">服务类别</p>
          <el-table
              :data="tableData"
              border
              class="table"
              ref="multipleTable"
              header-cell-class-name="table-header"
          >
              <el-table-column prop="id" label="服务分类" align="center"></el-table-column>
              <el-table-column class="height" prop="name" label="排序" align="center"></el-table-column>
              <el-table-column
                  label="操作"
                  align="center"
                  >
                  <template slot-scope="scope">
                      <el-button class="red" @click="handleClick(scope.$index, scope.row)" type="text" size="small">查看</el-button>
                      <el-button class="red" type="text" size="small" @click="handleEdit(scope.$index,scope.row)">编辑</el-button>
                  </template>
              </el-table-column>
          </el-table>
          <div class="pagination">
              <el-pagination
                  background
                  layout="total, prev, pager, next"
                  :current-page="query.pageIndex"
                  :page-size="query.pageSize"
                  :total="pageTotal"
                  @current-change="handlePageChange"
              ></el-pagination>
          </div>
      </div>
  </div>
</template>

<script>
import { serve } from '../../../api/index';
export default {
  name: 'basetable',
  data() {
      return {
          query: {
              name: '',
              pageNum: 1,
              pageSize: 2,
              phone:'',
          },
          tableData: [],
          pageTotal: 0,
      };
  },
  created() {
      this.getData();
  },
  methods: {
      // 获取 easy-mock 的模拟数据
      getData() {
        serve(this.query).then(res => {
              console.log(res);
              this.tableData = res.list;
              this.pageTotal = res.pageTotal || 50;
          });
      },
      // 触发保存按钮
      handleKeep() {
          this.$set(this.query, 'pageIndex', 1);
          this.getData();
      },
      //查看按钮
      handleClick(index,row){
        console.log('查看',row);
      },
      //编辑按钮
      handleE(index,row){
        console.log('编辑',row);
      },
      handlePageChange(val) {
          this.$set(this.query, 'pageIndex', val);
          this.getData();
      }
  }
};
</script>

<style scoped>
.handle-box {
  margin-bottom: 30px;
  padding: 20px 60px;
}
.handle-select {
  width: 120px;
}
.red{
  color: #ff0000;
}
.mt{
  margin-top:10px;
}
.Btn{
  padding: 10px 40px;
}
.gre{
  color: rgb(121,195,203);
}
.mg{
  margin: 20px 0;
}
.handle-input {
  width: 300px;
  display: inline-block;
}
.table {
  width: 100%;
  font-size: 14px;
  margin-top: 30px;
}
.red {
  color: #ff0000;
}
.mr10 {
  margin-right: 40px;
}
.mt{
  margin-top: 20px;
}
.table-td-thumb {
  display: block;
  margin: auto;
  width: 40px;
  height: 40px;
}
</style>
